<?php

function criar_thumb($origem, $datada, $destino,$estilo,$largura='60', $altura='40',$pre='',$formato='JPEG') { 

    switch($formato) 

    { 

        case 'JPEG': 

            $tn_formato = 'jpg'; 

            break; 

        case 'PNG': 

            $tn_formato = 'png'; 

            break; 

    } 

    $ext = split("[/\\.]",strtolower($origem)); 

    $n = count($ext)-1; 

    $ext = $ext[$n]; 



    $arr = split("[/\\]",$origem); 

    $n = count($arr)-1; 

    $arra = explode('.',$arr[$n]); 

    $n2 = count($arra)-1;

    

    if ($ext == 'jpg' || $ext == 'jpeg'){ 

        $im = imagecreatefromjpeg($origem); 

    }elseif($ext == 'png'){ 

        $im = imagecreatefrompng($origem); 

    }elseif($ext == 'gif'){ 

        $im = @ImageCreateFromGIF($origem); 

    } 

    $w = imagesx($im); 

    $h = imagesy($im); 

    

	if ($w > $h) 

    { 

        $nw = $largura; 

        $nh = $altura;

		$destino = $destino.$datada.$estilo.'.'.$tn_formato; 

    }else{ 

        $nw = $largura;

		$nh = $altura;

		$destino = $destino.$datada.$estilo.'.'.$tn_formato; 

    }

	

    if(function_exists('imagecopyresampled')) 

    { 

        if(function_exists('imageCreateTrueColor')) 

        { 

            $ni = imageCreateTrueColor($nw,$nh); 

        }else{ 

            $ni    = imagecreate($nw,$nh); 

        } 

        if(!@imagecopyresampled($ni,$im,0,0,0,0,$nw,$nh,$w,$h)) 

        { 

            imagecopyresized($ni,$im,0,0,0,0,$nw,$nh,$w,$h); 

        } 

    }else{ 

        $ni    = imagecreate($nw,$nh); 

        imagecopyresized($ni,$im,0,0,0,0,$nw,$nh,$w,$h); 

    } 

        imagejpeg($ni,$destino,100); 

}



function criar_foto($origem, $datada, $destino, $estilo, $largura='350',$pre='',$formato='JPEG') { 

    switch($formato) 

    { 

        case 'JPEG': 

            $tn_formato = 'jpg'; 

            break; 

        case 'PNG': 

            $tn_formato = 'png'; 

            break; 

    } 

    $ext = split("[/\\.]",strtolower($origem)); 

    $n = count($ext)-1; 

    $ext = $ext[$n]; 



    $arr = split("[/\\]",$origem); 

    $n = count($arr)-1; 

    $arra = explode('.',$arr[$n]); 

    $n2 = count($arra)-1; 



    if ($ext == 'jpg' || $ext == 'jpeg'){ 

        $im = imagecreatefromjpeg($origem); 

    }elseif($ext == 'png'){ 

        $im = imagecreatefrompng($origem); 

    }elseif($ext == 'gif'){ 

        $im = @ImageCreateFromGIF($origem); 

    } 

    $w = imagesx($im); 

    $h = imagesy($im); 

    

	if ($w > $h) 

    { 

        $nw = $largura; 

        $nh = ($h * $largura)/$w;

		$destino = $destino.$datada.$estilo.'.'.$tn_formato;

    }else{ 

        $nh = $largura; 

        $nw = ($w * $largura)/$h;

		$destino = $destino.$datada.$estilo.'.'.$tn_formato; 

    }

	

    if(function_exists('imagecopyresampled')) 

    { 

        if(function_exists('imageCreateTrueColor')) 

        { 

            $ni = imageCreateTrueColor($nw,$nh); 

        }else{ 

            $ni    = imagecreate($nw,$nh); 

        } 

        if(!@imagecopyresampled($ni,$im,0,0,0,0,$nw,$nh,$w,$h)) 

        { 

            imagecopyresized($ni,$im,0,0,0,0,$nw,$nh,$w,$h); 

        } 

    }else{ 

        $ni    = imagecreate($nw,$nh); 

        imagecopyresized($ni,$im,0,0,0,0,$nw,$nh,$w,$h); 

    } 

        imagejpeg($ni,$destino,100); 

} 

?>